package com.han.spring.core.create_container;

import org.junit.Test;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.GenericApplicationContext;

/**
* @author hanpeng
* @version 创建时间：2020年7月6日 下午10:42:11
* @ClassName 类名称
* @Description 类描述
*/
@SuppressWarnings("resource")
public class ClassPathXmlApplicationContextTest {

	public static void main(String[] args) {
		//create_container.xml
		ApplicationContext context = new ClassPathXmlApplicationContext("create_container.xml");
		String applicationName = context.getDisplayName();
		System.out.println(applicationName);
		
		User user = context.getBean("com.han.spring.core.create_container.User", User.class);
		System.out.println(user);
		
	}
	@Test
	public void way2() {
		GenericApplicationContext context = new GenericApplicationContext();
		XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(context);
		int loadBeanDefinitions = xmlBeanDefinitionReader.loadBeanDefinitions("create_container.xml");
		context.refresh();
	}

}
